import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // 启动要显示的界面
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ListView"),
      ),
      body: MyHomeBody(),
    );
  }
}

class MyHomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          leading: Icon(Icons.people),
          title: Text("联系人${index+1}"),
          subtitle: Text("联系人电话${index+1}"),
          trailing: Icon(Icons.arrow_right),
        );
      },
      itemCount: 10,
      separatorBuilder: (BuildContext context, int index) {
        return Divider(
          // 每个Widget 之间的距离
          height: 30,
          // 距离左边的距离
          indent: 16,
          // 距离右边的距离
          endIndent: 16,
          // 每条分割线的高度
          thickness: 10,
          color: index % 2 == 0 ? Colors.red : Colors.green,
        );
      },
    );
  }
}
